package com.kele.goods.config;

import com.kele.goods.intercepter.TestHandlerInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyMVCConfig implements WebMvcConfigurer {

    /**
     * 添加拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // addPathPatterns表示对请求进行拦截，excludePathPatterns表示除了()请求之外
        registry.addInterceptor(new TestHandlerInterceptor()).addPathPatterns("/**");
    }
}
